home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_citrix.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  1.1 KB  |  55 lines

  1. /*
  2.   decode_citrix.c
  3.  
  4.   Citrix ICA.
  5.  
  6.   http://www.securityfocus.com/templates/archive.pike?list=1&date=200 \
  7.   0-04-15&msg=Pine.BSO.4.20.0003290949280.2640-100000@naughty.monkey.org
  8.   
  9.   Thanks to Jeremie Kass <jeremie@monkey.org> for providing me with
  10.   traffic traces.
  11.   
  12.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  13.  
  14.   $Id: decode_citrix.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  15. */
  16.  
  17. #include <sys/types.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "decode.h"
  21.  
  22. int
  23. decode_citrix(u_char *buf, int len)
  24. {
  25.     static u_char ica_magic[] = { 0x32, 0x26, 0x85, 0x92, 0x58 };
  26.     u_char key, *p, *end;
  27.     int i, lines;
  28.     
  29.     end = buf + len;
  30.     i = 0;
  31.     
  32.     for (p = buf; p != NULL && end - p > 60 && i < sizeof(Buf); ) {
  33.         if ((p = bufbuf(p, len, ica_magic, 5)) == NULL)
  34.             break;
  35.         
  36.         key = p[17]; p += 60;
  37.         Buf[i++] = (key | 'C') ^ p[0];
  38.         lines = 0;
  39.         
  40.         for (p++; p < end; p += 2) {
  41.             if (i > sizeof(Buf) - 1)
  42.                 break;
  43.             
  44.             if ((Buf[i++] = p[0] ^ p[1] ^ key) == '\0') {
  45.                 Buf[i - 1] = '\n';
  46.                 if (++lines >= 3)
  47.                     break;
  48.             }
  49.         }
  50.     }
  51.     Buf[i] = '\0';
  52.     
  53.     return (i);
  54. }
  55.